package com.ywk.pattern._27_interpreter;

public abstract class Expression {
    //解释器
    public void interpret(PlayContext context) {
        if (context.getText() == null || context.getText().length() == 0) {
            return;
        } else {
            String playKey = context.getText().substring(0, 1);
            context.setText(context.getText().substring(2));
            double playValue = Double.parseDouble(context.getText().substring(0, context.getText().indexOf(" ")));
            context.setText(context.getText().substring(context.getText().indexOf(" ") + 1));
            excute(playKey, playValue);
        }
    }

    public abstract void excute(String playKey, double playValue);
}
